﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="x-ua-compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="robots" content="none">
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="__PUBLIC__/bootstrap/css/bootstrap.min.css">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="__PUBLIC__/bootstrap/css/bootstrap-table.min.css">
    <!-- Toast -->
    <link rel="stylesheet" href="__PUBLIC__/bootstrap/css/toastr.min.css">
    <title><?php echo $title?></title>

    <style>
        .red_font { color: red }
        .red_cell {
            background-color: red;
            color: white;
        }

        html, body {
            height: 100%;
        }

        .main_layer {
            margin-top: -72px;
            padding-top: 72px;
            height: 100%;
        }
    </style>
</head>
<body>

<!-- 发送邮件弹出框 -->
<div class="modal fade" id="modal-mail">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">发送邮件</h4>
            </div>
            <form name="mail-form" class="form-horizontal" action="#" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">GUID</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="guid" placeholder="请输入接收邮件玩家GUID">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">标题</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="subject" placeholder="请输入标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">内容</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" name="body" placeholder="请重新输入内容" rows="5"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">发送的金币数量</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="money" placeholder="请输入金币数量">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">发送的道具ID</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="item_guid" placeholder="请输入道具ID">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">发送的道具数量</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="item_count" placeholder="请输入道具数量">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button  name="send-mail" type="button" class="btn btn-primary">发送邮件</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- 发送邮件弹出框结束 -->

<header class="container-fluid">
    <div class="navbar navbar-inverse">
        <div class="navbar-inner">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">后台</a>
            </div>
            <div class="container-fluid">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="{:U('Admin/Admin/gm_logout')}">退出登录</a></li>
                </ul>
            </div><!-- Container -->
        </div><!-- Nav Bar - Inner -->
    </div><!-- Nav Bar -->
</header><!-- /container -->


<!-- 主框架 -->
<div class="container-fluid main_layer">
    <div class="row">
        <div class="col-sm-2">
            <ul id="nav-tab" class="nav nav-pills nav-stacked" role="tablist">
                <li role="presentation" class="active"><a href="#user_list" aria-controls="user_list" data-toggle="tab">玩家列表</a></li>
                <li role="presentation"><a href="#chara_list" aria-controls="chara_list" data-toggle="tab">角色列表</a></li>
                <li role="presentation"><a href="#mail_list" aria-controls="mail_list" data-toggle="tab">邮件列表</a></li>
                <li role="presentation"><a href="#item_search" aria-controls="item_search" data-toggle="tab">查找道具</a></li>
            </ul>
        </div>
        <div class="col-sm-10">
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane fade in active" id="user_list">
                    <table
                            data-toggle="table"
                            data-show-refresh="true"
                            data-show-columns="true"
                            data-minimum-count-columns="2"
                            data-pagination="true"
                            data-id-field="id"
                            data-page-list="[10, 15, 25, 50, 100, ALL]"
                            data-show-footer="false"
                            data-side-pagination="server"
                            data-url="{:U('Api/Account/user_list')}"
                    >
                        <thead>
                        <tr>
                            <th data-field="id">ID</th>
                            <th data-field="username">用户名</th>
                            <th data-field="gmlevel">帐号等级</th>
                            <th data-field="email">邮箱</th>
                            <th data-field="joindate">加入时间</th>
                            <th data-field="last_ip">最后登录IP</th>
                            <th data-field="last_login">最后登录时间</th>
                            <th data-field="locked">是否锁定</th>
                            <th data-field="failed_logins">登录失败次数</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane fade" id="chara_list">
                    <table
                            data-toggle="table"
                            data-show-refresh="true"
                            data-show-columns="true"
                            data-minimum-count-columns="2"
                            data-pagination="true"
                            data-id-field="id"
                            data-page-list="[10, 15, 25, 50, 100, ALL]"
                            data-show-footer="false"
                            data-side-pagination="server"
                            data-url="{:U('Api/Character/chara_list')}"
                    >
                        <thead>
                        <tr>
                            <th data-field="guid">GUID</th>
                            <th data-field="account">帐号</th>
                            <th data-field="name">角色名</th>
                            <th data-field="level">等级</th>
                            <th data-field="money">金币</th>
                            <th data-field="totaltime">总在线时间(分钟)</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane fade" id="mail_list">
                    <div id="mail-table-toolbar">
                        <button class="btn btn-default" data-toggle="modal" data-target="#modal-mail">发送邮件</button>
                    </div>
                    <table
                            data-toggle="table"
                            data-toolbar="#mail-table-toolbar"
                            data-show-refresh="true"
                            data-show-columns="true"
                            data-minimum-count-columns="2"
                            data-pagination="true"
                            data-id-field="id"
                            data-page-list="[10, 15, 25, 50, 100, ALL]"
                            data-show-footer="false"
                            data-side-pagination="server"
                            data-url="{:U('Api/Mail/mail_list')}"
                    >
                        <thead>
                        <tr>
                            <th data-field="id">邮件编号</th>
                            <th data-field="receiver">接收玩家</th>
                            <th data-field="subject">标题</th>
                            <th data-field="body">内容</th>
                            <th data-field="money">发送的金币</th>
                            <th data-field="state">处理情况</th>
                            <th data-field="time">添加时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane fade" id="item_search">
                    <table
                            data-toggle="table"
                            data-search="true"
                            data-show-refresh="true"
                            data-show-columns="true"
                            data-minimum-count-columns="2"
                            data-id-field="entry"
                            data-show-footer="false"
                            data-url="{:U('Api/Item/item_search')}"
                            data-side-pagination="client"
                            data-pagination="true"
                            data-page-list="[10, 15, 25, 50, 100, ALL]"
                    >
                        <thead>
                        <tr>
                            <th data-field="entry">ENTRY</th>
                            <th data-field="name">名字</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 主框架结束 -->

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="__PUBLIC__/bootstrap/js/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="__PUBLIC__/bootstrap/js/bootstrap-table.min.js"></script>
<!-- Latest compiled and minified Locales -->
<script src="__PUBLIC__/bootstrap/js/locale/bootstrap-table-zh-CN.min.js"></script>
<!-- Toast -->
<script src="__PUBLIC__/bootstrap/js/toastr.min.js"></script>

<script>
    $(document).ready(function(){
        $("button[name='send-mail']").on('click', function(){
            var args = {};
            $("form[name='mail-form'] input").map(function(){
                args[$(this).attr("name")] = $(this).val();
            });
            $("form[name='mail-form'] textarea").map(function(){
                args[$(this).attr("name")] = $(this).val();
            });
            ajaxRequest("{:U('Api/Mail/send_mail')}", args, function(err, data){
                if (err) {
                    console.log(err);
                } else {
                    if (data.code != 0) {
                        toastr.error(data.desc);
                    } else {
                        $("div[id='modal-mail']").modal('hide');
                        toastr.success('邮件发送成功！');
                    }
                }
            });
        });
    });
    function ajaxRequest(url, args, callback) {
        $.ajax({
            url: url,
            async: true,
            dataType: 'json',
            type: 'POST',
            data: args,
            success: function(data , textStatus){
                callback(null, data);
            },
            error: function(jqXHR , textStatus , errorThrown){
                callback(errorThrown);
            },
        });
    }
</script>
</body>
</html>
